package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) throws IOException {

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入文件名");
        String ooo = scan.nextLine();
        FileOutputStream fos = new FileOutputStream(ooo);
        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);
        System.out.println("请开始输入内容，单独输入exit时退出！");

        while(true) {
            String line = scan.nextLine();

            if ("exit".equals(line)) {
                break;
            }
            pw.println(line);
        }
        pw.close();
        System.out.println("再见！");




//        FileOutputStream fos = new FileOutputStream("pw.txt");
//        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
//
//        BufferedWriter bw = new BufferedWriter(osw);
//        PrintWriter pw = new PrintWriter(bw);
//
//        pw.println("你会挽着我的衣袖~");
//        pw.println("我会把手踹进裤兜~");
//        System.out.println("写出完毕！");
//        pw.close();












    }
}
